package com.firefightingiot.firefightingiot.web.web;

import cn.hutool.json.JSONObject;
import com.firefightingiot.firefightingiot.common.base.BaseController;
import com.firefightingiot.firefightingiot.support.annotaion.Action;
import com.firefightingiot.firefightingiot.support.annotaion.At;
import com.firefightingiot.firefightingiot.support.model.RespEntity;
import com.firefightingiot.firefightingiot.web.service.IPSoundColumnService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * 消防物联网首页数据统计控制器
 */
@Action
@RequestMapping(value="iPSound")
public class IPSoundColumnController extends BaseController {
    @Resource
    public IPSoundColumnService ipSoundColumnService;

    /**
     * 注册到中间件
     * @param
     * @return
     */
    @At(value = "init", method = RequestMethod.GET)
    public RespEntity init(@RequestBody(required = false) JSONObject jsonParam) {
        return ipSoundColumnService.init();
    }
    /**
     * 设置中间件状态，设置中间件状态，开启自动发送状态帧模式 2，状态变化时发送
     * @param
     * @return
     */
    @At(value = "setMvState", method = RequestMethod.GET)
    public RespEntity setMvState(@RequestBody(required = false) JSONObject jsonParam) {
        return ipSoundColumnService.mv_state();
    }
    /**
     * 上传文件到NAS
     * @param jsonParam
     * @return
     */
    @At(value = "uploadMediaFile", method = RequestMethod.POST)
    public RespEntity uploadMediaFile(@RequestBody(required = false) JSONObject jsonParam) {
        return ipSoundColumnService.uploadMediaFile(jsonParam);
    }
    /**
     * 删除文件（NAS 和 Windows）
     * @param jsonParam
     * @return
     */
    @At(value = "deleteMediaFile", method = RequestMethod.POST)
    public RespEntity deleteMediaFile(@RequestBody(required = false) JSONObject jsonParam) {
        return ipSoundColumnService.deleteMediaFile(jsonParam);
    }

    /**
     * 请求编辑执行任务
     * @param jsonParam
     * @return
     */
    @At(value = "publishAudio", method = RequestMethod.POST)
    public RespEntity publishAudio(@RequestBody(required = false) JSONObject jsonParam) {
        return ipSoundColumnService.publishAudioNew(jsonParam);
    }

    /**
     * 发布或播放列表
     * @param jsonParam
     * @return
     */
    @At(value = "publishOrPlayList", method = RequestMethod.GET)
    public RespEntity publishOrPlayList(@RequestBody(required = false) JSONObject jsonParam) {
        return ipSoundColumnService.publishOrPlayList(jsonParam);
    }

    /**
     * 终止播放
     * @param jsonParam
     * @return
     */
    @At(value = "endPlay", method = RequestMethod.POST)
    public RespEntity endPlay(@RequestBody(required = false) JSONObject jsonParam) {
        return ipSoundColumnService.endPlayAsyn(jsonParam);
    }

    /**
     * 获取 SubID 指定任务的实时运行信息命令
     * @param jsonParam
     * @return
     */
    @At(value = "getTaskRunInfo", method = RequestMethod.GET)
    public RespEntity getTaskRunInfo(@RequestBody(required = false) JSONObject jsonParam) {
        return ipSoundColumnService.getTaskRunInfo(jsonParam);
    }

    /**
     * 根据 设备id 设置音量
     * @param jsonParam
     * @return
     */
    @At(value = "setTaskVolume", method = RequestMethod.POST)
    public RespEntity setTaskVolume(@RequestBody(required = false) JSONObject jsonParam) {
        return ipSoundColumnService.setTaskVolumeNew(jsonParam);
    }

    /**
     * 获取设备音量，并显示设备音量
     * @param jsonParam
     * @return
     */
    @At(value = "showDeviceVolume", method = RequestMethod.POST)
    public RespEntity showDeviceVolume(@RequestBody(required = false) JSONObject jsonParam) {
        return ipSoundColumnService.showDeviceVolume(jsonParam);
    }
}
